import http from '@/utils/request';
import { Local } from '@/utils/storage';

export function userLogin(data: object) {
	return http.request({
		method: 'POST',
		url: '/auth/toc-token/login',
		data,
		custom: {
			skipToken: true,
		},
	});
}
// 小程序登录
export function maLogin(data: object) {
	return http.request({
		method: 'POST',
		url: '/auth/toc-token/ma/login',
		data,
		custom: {
			skipToken: true,
		},
	});
}
// 手机号验证码登录
export function phoneLogin(data: object) {
	return http.request({
		method: 'POST',
		url: '/auth/toc-token/sms/login',
		data,
		custom: {
			skipToken: true,
		},
		header: {
			// #ifdef MP-WEIXIN
			'wx-user-id': Local.get('wxUserId'),
			// #endif
		},
	});
}
// 手机号密码登录
export function passwordLogin(data: object) {
	return http.request({
		method: 'POST',
		url: '/auth/toc-token/password/login',
		data,
		custom: {
			skipToken: true,
		},
	});
}
// 小程序手机号一键登录
export function quickLogin(data: object) {
	return http.request({
		method: 'POST',
		url: '/auth/toc-token/ma/phone/login',
		data,
		custom: {
			skipToken: true,
		},
		header: {
			// #ifdef MP-WEIXIN
			'wx-user-id': Local.get('wxUserId'),
			// #endif
		},
	});
}
// 获取登录人信息
export function getUserInfo(params: object) {
	return http.request({
		method: 'GET',
		url: '/mall-user/app/userinfo',
		params,
	});
}
// 退出登录
export function userLogout(params: object) {
	return http.request({
		method: 'DELETE',
		url: '/auth/toc-token/logout',
		params,
	});
}
// 发送短信验证码
export function sendSmsCode(type: string, phone: string) {
	return http.request({
		method: 'GET',
		url: '/upms/sms/' + type + '/' + phone,
		custom: {
			skipToken: true,
		},
	});
}
